Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helix-term: add config option for specifying log file #566

Closed
wants to merge 5 commits into from

Conversation

dsseng
Copy link
Contributor

@dsseng dsseng commented Aug 9, 2021

No description provided.

helix-term/src/main.rs Outdated Show resolved Hide resolved
Copy link
Member

@archseer archseer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I've been holding off on this because I'm not sure if this is something that's really needed and can cause confusion if the user changed the path and forgot. I kind of like having one canonical location. I'm not too decided on this so let's get some more input from others.

pub struct Config {
pub theme: Option<String>,
pub log_file: Option<String>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would call this log-path rather than log file. You can also use Option<PathBuf> here to parse straight into a PathBuf.

Err(err) if err.kind() == std::io::ErrorKind::NotFound => Config::default(),
Err(err) => return Err(Error::new(err)),
};
let log_dir = log_path.parent().unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be .context("unable fetch parent path")?

@dsseng
Copy link
Contributor Author

dsseng commented Aug 16, 2021

Yes, moving log out and forgetting about it won't be good for support, but how to disable log? It often gets flooded with messages on default settings.

@cessen
Copy link
Contributor

cessen commented Aug 16, 2021

In general I'm in favor of things like this being configurable, but I also think it's probably best to leave it non-configurable until someone has a concrete use-case for it. Knowing why someone needs/wants to change the location will help in deciding how it should be implemented (e.g. should it be in the config vs environment variable vs command-line flag, does it need to be completely disabled in some cases, etc. etc. etc.).

So my suggestion is we drop this for now, and if someone comes along in the future with a concrete need/desire for it, we can implement it then.

@dsseng
Copy link
Contributor Author

dsseng commented Aug 17, 2021

Well, I made this for the exact use case, so my primary build of Helix I use for editing everything includes this patch. Once I had terminated rust-analyzer by accident from task manager and got 500+ MB of log data with some errors. Then I've decided to be able to drop logs unless debugging stuff. Anyway, if a bug is present user can restart Helix after re-enabling logs and collect everything necessary for report.

@archseer
Copy link
Member

Note: in your current implementation if you leave the logfile unset it doesn't actually disable logs but falls back to the system log location.

I think to solve log bloat we should raise the default log level to error, then make sure to only print errors which are actually useful for debugging. Setting a max logfile size can work too

@archseer
Copy link
Member

@dsseng
Copy link
Contributor Author

dsseng commented Aug 17, 2021

Note: in your current implementation if you leave the logfile unset it doesn't actually disable logs but falls back to the system log location.

I think to solve log bloat we should raise the default log level to error, then make sure to only print errors which are actually useful for debugging. Setting a max logfile size can work too

Probably loglevel rise would be a good fix, thank you. As for now I didn't implement disabling by this PR, but can do it if PR is planned to go in. I disable it by redirecting to /dev/null, macOS users can do this as well, but for others it'll be required to disable logs when passed arg is ""

@archseer
Copy link
Member

Dropping this for now, we'll add it if it becomes necessary -- we log far less now without the -v flag and the LSP crash issue was resolved

@archseer archseer closed this Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants